import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.Pipeline;

import java.util.List;

/**
 * @Auther: tianchao
 * @Date: 2021/11/26 23:13
 * @Description:
 */
public class PipelineTest {
    public static void main(String[] args) {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(20);
        jedisPoolConfig.setMaxIdle(10);
        jedisPoolConfig.setMinIdle(5);
        JedisPool jedisPool = new JedisPool(jedisPoolConfig, "192.168.10.200", 6379, 3000, null);
        try {
            Jedis jedis = jedisPool.getResource();
            Pipeline pipelined = jedis.pipelined();
            for (int i = 0; i < 10; i++) {
                pipelined.incr("pipelineKey");
                pipelined.set("tianchao"+i, "tianchao"+i);
            }
            List<Object> objects = pipelined.syncAndReturnAll();
            objects.stream().forEach(System.out::println);
        }catch (Exception e){

        }
    }
}
